package 力扣_简单题;

import java.util.Stack;

/**
 * @author 连安利
 * @version 1.0
 * @date 2021/4/1 13:27
 */
public class 用两个栈实现队列 {
    Stack<Integer> stack1;
    Stack<Integer> stack2;
    public void CQueue() {
      stack1 = new Stack<Integer>();
      stack2 = new Stack<Integer>();
    }

    public void appendTail(int value) {
        stack1.push(value);
    }

    public int deleteHead() {
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        if(stack2.isEmpty()){
            return -1;
        }
        else{
            return stack2.pop();
        }
    }
}
